<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
    {include file="public/meta"}
    <!--/meta 作为公共模版分离出去-->
    <title></title>
    <meta name="keywords" content="">
    <meta name="description" content="">
</head>
<body>
<div class="wap-container">
    <nav class="breadcrumb" style="background-color:#fff;padding: 0 24px">
        作者后台
        <span class="c-gray en">/</span>
        书籍管理
        <span class="c-gray en">/</span>
        书籍列表
        <a class="btn btn-success radius f-r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
    </nav>
    <article class="Hui-admin-content clearfix">
        <div class="panel mt-20">
            <div class="panel-body">
                <div class="clearfix">
						<span class="f-l">
							<a href="javascript:;" onclick="member_add('添加书籍','/author/book/add')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加书籍</a>
						    <!--<a href="javascript:;" onclick="admin_add('添加管理员','/author/book/add')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加管理员</a>-->
                        </span>
                    <span class="f-r">共有数据：<strong>{$total}</strong> 条</span>
                </div>
                <div class="clearfix mt-20">
                    <table class="table table-border table-bordered table-hover table-bg table-sort">
                        <thead>
                        <tr class="text-c">
                            <th width="80">ID</th>
                            <th width="100">书名</th>
                            <th width="40">封面</th>
                            <th width="90">类别</th>
                            <th width="150">字数</th>
                            <th width="50">推荐次数</th>
                            <th width="50">打赏人数</th>
                            <th width="50">状态</th>
                            <th width="100">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="book" id="vo"}
                        <tr class="text-c">
                            <td>{$vo.id}</td>
                            <td>{$vo.name}</td>
                            <td><img src="{$vo.cover}" style="width:40px;" alt=""></td>
                            <td>{$vo.cate_name}</td>
                            <td>{$vo.words}</td>
                            <td>{$vo.tuijian}</td>
                            <td>{$vo.dasang}</td>
                            <td>{if $vo.state eq 1}
                                <span class="label label-success radius">正常</span>
                                {else/}
                                <span class="label label-defaunt radius">待审核</span>
                                {/if}
                            </td>
                            <!--<td class="td-status">-->
                                <!--{if $vo.complete eq 0}-->
                                <!--<span class="label label-success radius">未完本</span>-->
                                <!--{else/}-->
                                <!--<span class="label label-defaunt radius">已完本</span>-->
                                <!--{/if}-->
                            <!--</td>-->
                            <td class="td-manage">
                                {if $vo.complete eq 0}
                                <a style="text-decoration:none" onClick="member_stop(this,'{$vo.id}')" href="javascript:;" title="">未完本</a>
                                {else/}
                                <a style="text-decoration:none" onClick="member_start(this,'{$vo.id}')" href="javascript:;" title="">完本</a>
                                {/if}
                                <!--<a title="编辑" href="javascript:;" onclick="member_edit('编辑','/author/book/edit/id/{$vo.id}','{$vo.id}')" class="ml-5" style="text-decoration:none">编辑</a>-->
                                <!--<a title="删除" href="javascript:;" onclick="member_del(this,'{$vo.id}')" class="ml-5" style="text-decoration:none">删除</a>-->
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </article>
</div>
<!--_footer 作为公共模版分离出去-->
{include file="public/footer"}
<!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/author/lib/datatables/1.10.15/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/static/author/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="/static/author/static/business/js/main.js"></script>
<script type="text/javascript">
    $(function(){
        runDatetimePicker();
        // 全选 页面调用
        $(".table").HuicheckAll(
            {
                checkboxAll: 'thead input[type="checkbox"]',
                checkbox: 'tbody input[type="checkbox"]'
            },
            function(checkedInfo) {
                console.log(checkedInfo);
            }
        );
    });
    //添加
    function member_add(title,url){
        var index = layer.open({
            type: 2,
            title: title,
            content: url,
        });
        layer.full(index);
    }
    //编辑
    function member_edit(title,url){
        var index = layer.open({
            type: 2,
            title: title,
            content: url,
        });
        layer.full(index);
    }
    //删除
    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            var url = "/author/book/delete";
            $.post(url,{id:id},function(data){
                if(data.state === 200){
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:1000});
                }else{
                    layer.msg('删除失败!',{icon:2,time:1000});
                }
            });
        });
    }
    /*用户-停用*/
    function member_stop(obj,id){
        layer.confirm('设置为已完本',function(index){
            $.post("/author/book/done",{id:id},function(data){
                // alert(data);
                // console.log(data);
                if(data.state === 200){
                    $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="member_start(this,+id+)" href="javascript:;" title="启用">yes</a>');
                    $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已完本</span>');
                    $(obj).remove();
                    layer.msg('已完本!',{icon: 6,time:1000});
                }else{
                    layer.msg('更改失败',{icon: 5,time:1000});
                }
            });
        });
    }

    /*用户-启用*/
    function member_start(obj,id){
        layer.confirm('设置为未完本',function(index){
            $.post("/author/book/undone",{id:id},function(data){
                // console.log(data);
                if(data.state === 200){
                    $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="member_stop(this,+id+)" href="javascript:;" title="">no</a>');
                    $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">未完本</span>');
                    $(obj).remove();
                    layer.msg('未完本!',{icon: 6,time:1000});
                }else{
                    layer.msg('更改失败',{icon: 5,time:1000});
                }
            });

        });
    }
    $.get("/index/index/crontab",function(){});
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>
